﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traceability.Domain;

namespace Traceability.Infrastructure
{
    public class TraceabilityDbContext : DbContext
    {
        public TraceabilityDbContext(DbContextOptions options) : base(options)
        {
        }
        public DbSet<T_Traceability> T_Traceability { get; set; }
        public DbSet<T_Goods> T_Goods { get; set; }
        public DbSet<T_Photos> T_Photos { get; set; }
        public DbSet<T_Aquaculture> T_Aquacultures { get; set; }
        public DbSet<T_Health> T_Healths { get; set; }
        public DbSet<T_Company> T_Company { get; set; }
        public DbSet<T_Slaughter> T_Slaughters { get; set; }
        public DbSet<T_CompanyAddress> T_CompanyAddresses { get; set; }
        public DbSet<T_DeepProcess> T_DeepProcess { get; set; }
        public DbSet<T_Supplier> T_Suppliers { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<T_Traceability>()
                .HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<T_Goods>()
                .HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<T_Health>()
                .HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<T_Photos>()
                .HasQueryFilter(p => !p.IsDelete);
        }
    }
}
